Conditions | 1 |
Paths | 1 |
Total Lines | 61 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | define([ |
||
7 | ], function(_, messenger, __, DeleteConfirmation, DeleteAction) { |
||
8 | 'use strict'; |
||
9 | |||
10 | var PaymentDeleteAction; |
||
11 | |||
12 | /** |
||
13 | * Delete action with confirm dialog, triggers REST DELETE request |
||
14 | * |
||
15 | * @export oro/datagrid/action/payment_delete-action |
||
16 | * @class oro.datagrid.action.PaymentDeleteAction |
||
17 | * @extends oro.datagrid.action.DeleteAction |
||
18 | */ |
||
19 | PaymentDeleteAction = DeleteAction.extend({ |
||
20 | |||
21 | /** @property {Function} */ |
||
22 | confirmModalConstructor: DeleteConfirmation, |
||
23 | |||
24 | /** @property {String} */ |
||
25 | confirm_content: __('Are you sure you want to delete this item?'), |
||
26 | |||
27 | /** |
||
28 | * @inheritDoc |
||
29 | */ |
||
30 | constructor: function PaymentDeleteAction() { |
||
31 | PaymentDeleteAction.__super__.constructor.apply(this, arguments); |
||
32 | }, |
||
33 | |||
34 | /** |
||
35 | * @inheritDoc |
||
36 | */ |
||
37 | initialize: function(options) { |
||
|
|||
38 | if (this.model.has('payment_delete_message')) { |
||
39 | this.confirm_content = this.model.get('payment_delete_message'); |
||
40 | } |
||
41 | |||
42 | DeleteAction.__super__.initialize.apply(this, arguments); |
||
43 | }, |
||
44 | |||
45 | /** |
||
46 | * Get view for confirm modal |
||
47 | * |
||
48 | * @return {oroui.Modal} |
||
49 | */ |
||
50 | getConfirmDialog: function(callback) { |
||
51 | if (!this.confirmModal) { |
||
52 | this.confirmModal = (new this.confirmModalConstructor({ |
||
53 | title: __(this.messages.confirm_title), |
||
54 | content: this.confirm_content, |
||
55 | okText: __(this.messages.confirm_ok), |
||
56 | cancelText: __(this.messages.confirm_cancel) |
||
57 | })); |
||
58 | this.listenTo(this.confirmModal, 'ok', callback); |
||
59 | |||
60 | this.subviews.push(this.confirmModal); |
||
61 | } |
||
62 | return this.confirmModal; |
||
63 | } |
||
64 | }); |
||
65 | |||
66 | return PaymentDeleteAction; |
||
67 | }); |
||
68 |
This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.